<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>js动画及velocity动画</title>
		
	</head>
	<body>
		<div id="jscartoon">
			<transition
				name="header"
				@before-leave="handleBeforeLeave"
				@leave="handleLeave"
				@after-leave="handleAfterLeave">
				<div v-show="show"><h1>Hello World</h1></div>
			</transition>
			<button type="button" @click="handleClick">toggle</button>
		</div>
		
		<script src="js/vue.js"></script>
		<script src="js/velocity.min.js"></script>
		<script>
			
			
			let vm = new Vue({
				el:"#jscartoon",
				data:{
					show:true
				},
				methods:{
					handleClick:function(){
						this.show = !this.show
					},
					handleBeforeLeave:function(el){
						// el.style.color = 'red'
						el.style.opacity = 1;
					},
					handleLeave(el,done){
						/* setTimeout(() => {
							el.style.color = 'green'
						},2000)
						
						setTimeout(() => {
							done()
						},4000) */
						Velocity(el,{opacity:0},{duration:1000,complete:done});
					},
					handleAfterLeave:function(el){
						// el.style.color = "#000"
						console.log("动画结束");
						el.style.opacity = 1
					}
					
					
					
				}
			})
		</script>
	</body>
</html>
